package a.f;

import a.c.d;
import a.c.v;
import a.c.z;
import a.i.l;

import java.util.*;

public class bd
{
  public static final Object a = "y.layout.PortCandidateSet.DP_KEY";
  static final Comparator b = new b_();
  private List d = new ArrayList();
  private long e;
  public static int f;
  
  public void a(ad paramad)
  {
    a(paramad, 1);
  }
  
  public void a(ad paramad, int paramInt)
  {
    if (!o.eg)
    {
      if (paramInt > 0) {
        this.e += paramInt;
      }
    }
    else {
      this.d.add(new a_(paramad, paramInt));
    }
  }
  
  public int a()
  {
    if (!o.eg) {}
    return this.e > 2147483647L ? 2147483647 : (int)this.e;
  }
  
  public void a(e_ parame_)
  {
    int i = this.d.indexOf(parame_);
    if (!o.eg)
    {
      if (i < 0) {
        return;
      }
      this.d.remove(i);
    }
  }
  
  public Iterator b()
  {
    return this.d.iterator();
  }
  
  public d_ c()
  {
    return new c_(this.d);
  }
  
  protected double a(e_ parame_, d paramd, boolean paramBoolean, double paramDouble1, double paramDouble2)
  {
    if (!o.eg) {
      if (parame_.a().b()) {
        return parame_.a().f();
      }
    }
    return parame_.a().f();
  }
  
  protected double a(e_ parame_, d paramd, boolean paramBoolean)
  {
    return -parame_.a().f();
  }
  
  public static abstract interface e_
  {
    public abstract ad a();
    
    public abstract int b();
  }
  
  static final class a_
    implements bd.e_
  {
    ad a;
    int b;
    int c;
    
    a_(ad paramad, int paramInt)
    {
      this.a = paramad;
      this.c = paramInt;
      this.b = paramInt;
    }
    
    public a_(a_ parama_)
    {
      this(parama_.a, parama_.c);
    }
    
    public int b()
    {
      return this.b;
    }
    
    public ad a()
    {
      return this.a;
    }
    
    public String toString()
    {
      return "PortCandidateSet.Entry(candidate=" + this.a + ", connections=" + this.b + ')';
    }
  }
  
  static final class b_
    implements Comparator
  {
    public int compare(Object paramObject1, Object paramObject2)
    {
      bd.a_ locala_1 = (bd.a_)paramObject1;
      bd.a_ locala_2 = (bd.a_)paramObject2;
      return l.a(locala_2.a().f(), locala_1.a().f());
    }
  }
  
  final class c_
    implements bd.d_
  {
    z a = new z();
    
    c_(Collection paramCollection)
    {
      Iterator localIterator = paramCollection.iterator();
      if (localIterator.hasNext()) {}
      while (bool)
      {
        bd.a_ locala_ = (bd.a_)localIterator.next();
        this.a.add(new bd.a_(locala_));
        if ((!bool) && (i != 0)) {
          return;
        }
        if (i == 0) {
          break;
        }
      }
      this.a.a(bd.b);
    }
    
    public bd.e_ a()
    {
      boolean bool = o.eg;
      if (!bool) {
        if (this.a.isEmpty()) {
          throw new IllegalStateException("No candidates left");
        }
      }
      bd.a_ locala_ = (bd.a_)this.a.a();
      locala_.c -= 1;
      if (!bool) {
        if (locala_.c <= 0) {
          this.a.h(this.a.f());
        }
      }
      return locala_;
    }
    
    public bd.e_ a(d paramd, boolean paramBoolean, int paramInt)
    {
      boolean bool = o.eg;
      int i = o.dg;
      if (this.a.isEmpty()) {
        throw new IllegalStateException("No candidates left");
      }
      Object localObject1 = null;
      double d1 = -1.797693134862316E+308D;
      Object localObject2 = this.a.f();
      do
      {
        do
        {
          if (localObject2 == null) {
            break;
          }
          bd.a_ locala_ = (bd.a_)((v)localObject2).c();
          if (bool) {
            break label168;
          }
          if (i != 0) {
            break label165;
          }
          if (!bool)
          {
            if (locala_.a.a(paramInt))
            {
              double d2 = bd.this.a(locala_, paramd, paramBoolean);
              if (bool) {
                continue;
              }
              if (d2 > d1)
              {
                d1 = d2;
                localObject1 = localObject2;
              }
            }
            localObject2 = ((v)localObject2).a();
          }
        } while (i == 0);
      } while (bool);
      if (!bool) {
        if (localObject1 == null) {
          throw new IllegalStateException("No candidates left");
        }
      }
      label165:
      label168:
      localObject2 = (bd.a_)localObject1.c();
      localObject2.c -= 1;
      if (!bool) {
        if (((bd.a_)localObject2).c <= 0) {
          this.a.h(localObject1);
        }
      }
      return localObject2;
    }
    
    public bd.e_ a(d paramd, boolean paramBoolean, double paramDouble1, double paramDouble2, int paramInt)
    {
      boolean bool = o.eg;
      int i = o.dg;
      if (this.a.isEmpty()) {
        throw new IllegalStateException("No candidates left");
      }
      Object localObject1 = null;
      double d1 = 1.7976931348623157E+308D;
      Object localObject2 = this.a.f();
      do
      {
        do
        {
          if (localObject2 == null) {
            break;
          }
          bd.a_ locala_ = (bd.a_)((v)localObject2).c();
          if (bool) {
            break label208;
          }
          if (i != 0) {
            break label205;
          }
          if (!bool)
          {
            if (locala_.a.a(paramInt))
            {
              double d2 = bd.this.a(locala_, paramd, paramBoolean, paramDouble1, paramDouble2);
              if (!bool)
              {
                if (d2 > 0.0D)
                {
                  if (bool) {
                    continue;
                  }
                  if (d2 < d1)
                  {
                    d1 = d2;
                    localObject1 = localObject2;
                    if (bool) {
                      continue;
                    }
                    if (i == 0) {}
                  }
                }
                else
                {
                  if (bool) {
                    break label182;
                  }
                  localObject1 = localObject2;
                }
              }
              else {
                if (i == 0) {
                  break;
                }
              }
            }
            localObject2 = ((v)localObject2).a();
          }
        } while (i == 0);
      } while (bool);
      label182:
      if (!bool) {
        if (localObject1 == null) {
          throw new IllegalStateException("No candidates left");
        }
      }
      label205:
      label208:
      localObject2 = (bd.a_)localObject1.c();
      localObject2.c -= 1;
      if (!bool) {
        if (((bd.a_)localObject2).c <= 0) {
          this.a.h(localObject1);
        }
      }
      return localObject2;
    }
  }
  
  public static abstract interface d_
  {
    public abstract bd.e_ a(d paramd, boolean paramBoolean, double paramDouble1, double paramDouble2, int paramInt);
    
    public abstract bd.e_ a(d paramd, boolean paramBoolean, int paramInt);
    
    public abstract bd.e_ a();
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.bd

 * JD-Core Version:    0.7.0.1

 */